package com.dgh.school.mapper;

import com.dgh.school.bean.Clerk;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClerkMapper {


    @Select("select * from clerk")
    List<Clerk> selectAll() throws Exception;

    // 根据id删除数据
    @Delete("delete from clerk where cid = #{id}")
    void deleteById(int id) throws Exception;

    // 插入数据
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into clerk values (default, #{cname}, #{cgender},#{cage},#{cphone},#{cjoinTime},#{cdepartment},#{cduty},#{cemail})")
    void insert(Clerk clerk) throws Exception;


    @Update("update clerk set cname = #{cname},cgender = #{cgender},cage = #{cage},cphone = #{cphone},cjoin_time = #{cjoinTime},cdepartment = #{cdepartment},cduty = #{cduty},cemail = #{cemail} where cid = #{cid}")
    void update(Clerk clerk) throws Exception;
}
